<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>开户银行列表</title>
<link href="/resources/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="/resources/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="/resources/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="/resources/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
<script src="/resources/lib/ligerUI/js/ex/ligerGrid.showFilter.js" type="text/javascript"></script>
<script src="/resources/lib/ligerUI/js/ex/ligerFilterEx.js" type="text/javascript"></script>
<script src="/resources/js/selectData.js" type="text/javascript"></script>
<script src="/resources/js/themis.js" type="text/javascript"></script>
<script src="/resources/js/validation.js" type="text/javascript"></script>
<script type="text/javascript">
    var bool_data = [
                     { id: '1', value: '1', text: '是' },
                     { id: '0', value: '0', text: '否' }
                 ];
        var $grid;
        var form;
        $(function (){
        	//创建查询对象
        	/* form = $("#form2").ligerForm({
            	  inputWidth: 150, labelWidth: 80, space: 40,
                  fields: [ 
                      { label: "开户银行名", name: "userName", newline: false, type: "text", validate: {minlength: 5 } },
                      { label: "是否可用", name: "status", newline: false, type: "select",editor: {data:bool_data}}
                  ]
            });  */
            //创建表格对象 高级查询editor 识别编辑器有：combobox date number string
            $grid = $("#maingrid").ligerGrid({
                columns: [
                { name: 'uuid', hide:true,type:"text"},
                { display: '编码', name: 'number', width: 140,type:"text"},
                { display: '名称', name: 'name', width: 140,type:"text"}
                ],
                autoFilter:true,
                width: '100%', pageSizeOptions: [5, 10, 15, 20], height: '100%',
                checkbox: true,headerRowHeight:22, rowHeight:22, rownumbers:true,
                url:'/bank/listData',
                onLoadData:onloadData,
                onDblClickRow:onDblClickRow,
                toolbar: { items: [
                                   { text: '新增', click: addClick, icon: 'add' },
                                   { line: true },
                                   { text: '修改', click: alertClick, icon: 'modify' },
                                   { line: true },
                                   { text: '删除', click: delClick, icon: 'delete' }
                                   ]
                                   }
            });

        });
        //添加
        function addClick(item){
        	f_addTab('addBank','新增开户银行','/bank/addBank');
        }
        //双击事件(查看)
        function onDblClickRow(data, rowindex, rowobj){
        	f_addTab('viewBank','查看开户银行','/bank/viewBank?uuid='+data.uuid);

        }
        
        //删除
        function delClick(){
        	var rows = $grid.getSelectedRows();
        	if(rows == null || rows.length < 1){
        		$.ligerDialog.error("请至少选择一行数据");
        		return;
        	}
    		$.ajax({ 
    			url: '/bank/delBank', 
    			data:{rows : JSON.stringify(rows)}, 
    			type: "post", 
    			dataType:'json',
    			cache : false, 
    			success: function(data){
    				$.ligerDialog.success(data.message,'信息',function(){
    		        	 $grid.reload();
    				});
    			},
    	        error: function (message) {
    	            $.ligerDialog.error("删除失败");
    	        }
    	});
        }
        //修改
        function alertClick(){
        	var rows = $grid.getSelectedRows();
        	if(rows == null || rows.length < 1 || rows.length != 1){
        		$.ligerDialog.error("请选择一条要修改的数据");
        		return;
        	}
        	f_addTab('alterBank','修改开户银行','/bank/alterBank?uuid='+rows[0].uuid);
        }
        
        //查询
        function viewClick(){
        	//重新加载grid
        	 $grid.reload();
        }
        
      //获取数据前添加过滤条件
      function onloadData(){
    	/*   var cond = JSON.stringify(form.getData());
    	  this.options.parms.cond= cond;
    	  this.options.parms.temp= true; */
    	/*   applay(this.options.parms, [{ name: "cond", value: cond, temp: true }]); */
    	 //this.set('parms', [{ name: "cond", value: cond, temp: true }]);
      }
  	  //添加窗口
      function f_addTab(tabid,text, url){
  		this.parent.f_addTab(tabid,text, url);
      } 
    </script>
</head>
<body  style="padding:10px">
    <div id="maingrid"></div> 
</body>
</html>
